﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DTO;
using System.Data.SqlClient;

namespace DAO
{
    public class DangNhapDAO
    {
        public bool KiemTraDangNhap(string user, string pass, ref int ma, ref int bophan, ref string ten)
        {
            bool kt = false;
            SqlConnection conn = null;
            try
            {
                String sql = "select * from NHANVIEN where TaiKhoan = '" + user + "' and MatKhau =  '" + pass + "'";
                conn = DataProvider.ConnectDB();
                SqlCommand cmd = new SqlCommand(sql, conn);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    ma = reader.GetInt32(0);
                    ten = reader.GetString(1);
                    bophan = reader.GetInt32(7);
                }
                if (ma != 0)
                    kt = true;
            }
            catch (NullReferenceException)
            {
            }
            finally
            {
                if (conn != null)
                    conn.Close();
            }
            return kt;
        }
    }
}
